'use strict'

//获取走势图表底部表格数据
/**
 * @param {Number} content 彩种走势图星数
 * @param {String} lotteryType 彩票类型
 * @param {Object} self 调用该方法的this
 */
function getChartsPageInitDataFuc(self, lotteryType, content) {
    let params = {
        lottery_id: self.$route.params.caizhongID,
        limit: self.queryNum,
        star: content
    }
    if (!content) {
        delete params.star
    }
    self.axios
        .get("chart/getObtainTrendChartLimit", {
            params
        })
        .then(res => {
            if (res.data.status) {
                if (lotteryType != 'l28' && lotteryType != 'k3') {
                    for (var i = 0; i < 5; i++) {
                        self.recordPoint[i] = new Object();
                        for (var j = 0; j < 10; j++) {
                            self.recordPoint[i][j] = "";
                        }
                    }
                }
                self.tableTotalData = res.data.data;
                self.theadOneRowOtherTdData = [];
                self.theadTwoRowData = [];
                self.tableTotalData.titles.forEach(el => {
                    self.theadOneRowOtherTdData.push(el.title);
                    self.theadTwoRowData.push(el.numbers);
                });
                self.tbodyData = self.tableTotalData.list;
                if (lotteryType == 'l28' || lotteryType == 'k3') {
                    self.tbodySecondLastRowOtherTdData = self.tableTotalData.numberAppearCount;
                    self.tbodyLastRowOtherTdData = self.tableTotalData.currentOmission;
                } else {
                    self.tbodyData.forEach((elem, key) => {
                        elem.data.forEach((el, k) => {
                            el.forEach((item, i) => {
                                if (item.omission == 0) {
                                    self.recordPoint[k][i] = key;
                                }
                            });
                        });
                    });
                    self.tbodySecondLastRowOtherTdData = self.tableTotalData.appearCount;
                    self.tbodyLastRowOtherTdData = self.tableTotalData.maxOmissions;
                }
                self.haoMaFenBuTdData = self.tableTotalData.numberDistribution;
                self.longHuHeTdData = self.tableTotalData.dragonTiger1_5;
                self.isFuZhuXianChecked = true;
            } else {
                self.log(res.data.message);
            }
        })
        .catch(err => {
            self.log(err);
        });
}

export default getChartsPageInitDataFuc;